package com.wanmait.wanmarecruit.webController;

import com.wanmait.wanmarecruit.entity.Company;
import com.wanmait.wanmarecruit.entity.Recruiter;
import com.wanmait.wanmarecruit.service.impl.PositionServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("web")
public class WebCompanyIndexController {

    @Resource
    private PositionServiceImpl positionService;

    @RequestMapping("/companies/companyIndex")
    public ModelAndView companyIndex(HttpSession session){
        ModelAndView modelAndView = new ModelAndView();
        Integer companyId = ((Recruiter)session.getAttribute("hr")).getCompanyId();
        modelAndView.addObject("putOnPositionCount",positionService.getPutOnPositionCountById(companyId));
        modelAndView.addObject("userCount",positionService.getUserCountById(companyId));

        modelAndView.setViewName("/web/companies/companyIndex");
        return modelAndView;
    }

}
